<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>确定支付页面</title>
<link href="css/order/orderFifth.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-3.2.1.js"></script>
<script type="text/javascript">
$(function(){
	var way = 0;
    $(".div_payment_img1").click(function(){
    	$(this).css("border","2px solid #2999E1");
    	$(".div_payment_img2").css("border","none");
    	way = 1;
    })
   	
    
     $(".div_payment_img2").click(function(){
        $(this).css("border","2px solid #2999E1");
        $(".div_payment_img1").css("border","none");
        way = 2
    })
	
	$(".div_payment_button").click(function(){
		//顾客姓名
		var guke = $("[guke]").attr("guke");
		//车名
		var cheming = $("[cheming]").attr("cheming");
		//时间
		var getcartime = $("[getcartime]").attr("getcartime").substring(0,10);
		//地点
		var didian = $("[didian]").attr("didian");
		//电话
		var shouji = $("[shouji]").attr("shouji");
		
		//发送验证码
		$.post("https://api.mysubmail.com/message/xsend.json", {
			vars : {
				"a1" : guke,
				"a2" : cheming,
				"a3" : getcartime,
				"a4" : didian
			},
			appid : "17126",
			to : shouji,
			project : "FFsoy3",
			signature : "1c8cf1a0ae5184fb744e237d62fc5ef9"
		}, function(data) {
			alert(data.status);
		}, "json");
		alert(guke+","+cheming+","+getcartime+","+didian+","+shouji);
		if(way==1){
			location.href = "/fuhe/payali";
		}if(way==2){
			location.href = "/fuhe/wechat";
		}else{
			//保持在当前页
			//location.href = "javascript:void(0)";
		}
	})
	
	//为门店支付按钮添加点击事件
	$(".div_door_button").click(function(){
		alert("请于门店完成支付,正在为您返回首页");
		location.href = "/fuhe/ind"
	});
		
	
    $(".div_yue_button").click(function(){
    	//传递订单金额的值去处理余额支付的servlet中
    	//订单金额
    	 var ordermoney = $("input[name=ordermoney]").val();
    	//用户余额
    	 var yue=${user.account}
    	//订单号码
    	var ordernumber = $("[ordernumber]").attr("ordernumber");
    	//订单时间
	var getcartime = $("[getcartime]").attr("getcartime");
    	alert(getcartime);
    	if(yue<ordermoney){
    		alert("余额不足，请去个人中心充值");
    		//将界面转去个人中心充值界面
    		location.href="rechargemoney";
    		return;
    	}
    	//将订单金额以及余额的值传入servlet中
   	 $.ajax({
			url:"fee",
			type:"get",
			data:{ordermoney:ordermoney,yue:yue,ordernumber:ordernumber,getcartime:getcartime},
			datatype:"json",
			success:function(e){
			 alert(JSON.stringify(e));
			if(e=="订单支付成功"){
				//跳转到个人中心的订单页面
				location.href="order";

			}
			 location.href="payfifth";
	}
});

    	
    	
    });
 
    
    
    
    
    
    
    
})







</script>
</head>
<body>
	<jsp:include page="../public/header.jsp"></jsp:include>
	<div class="div_payment">

		<div class="div_payment_head">
			<span class="div_payment_head_span">选择支付方式</span>
		</div>

		<div class="div_payment_img1">
			<img src="img/serviceCompany/ali.png" / class="div_payment_img2_1">
		</div>
		<div class="div_payment_img2">
			<img src="img/serviceCompany/wechats.png" class="div_payment_img2_1" />
		</div>
		
			<input type="hidden" name="ordermoney" value="${oi.amount}">
			<input type="hidden" guke="${guke}">
			<input type="hidden" cheming="${cheming}">
			<input type="hidden" getcartime="${getcartime}">
			<input type="hidden" didian="${didian}">
			<input type="hidden" shouji="${shouji }"> 
			<input type="hidden" ordernumber="${oi.order_num}">
			<input type="button" value="确认收款" class="div_payment_button">
		<input type="button" value="门店支付" class="div_door_button">
		<input type="button" value="余额支付" class="div_yue_button">
	</div>
	<jsp:include page="../public/footer.jsp"></jsp:include>
</body>
</html>